export const getLabelById = (id, data) => {
    let datas = data.data1
    let label = ''
    for (let i = 0; i < datas.length; i++) {
      if (datas[i].id === id) {
        label = datas[i].name
      } else {
        if (datas[i].children) {
          for (let j = 0; j < datas[i].children.length; j++) {
            if (datas[i].children[j].id === id) {
              label = datas[i].children[j].name
            } else {
              if (datas[i].children[j].children) {
                for (let k = 0; k < datas[i].children[j].children.length; k++) {
                  if (datas[i].children[j].children[k].id === id) {
                    label = datas[i].children[j].children[k].name
                  }
                  if (label !== '') break
                }
              }
            }
            if (label !== '') break
          }
        }
      }
      if (label !== '') break
    }
    return label
  }
  

  // 只有年月日
export const formatDate = (secs) => {
    var t = new Date(secs)
    var year = t.getFullYear()
    var month = t.getMonth() + 1
    if (month < 10) {
      month = '0' + month
    }
    var date = t.getDate()
    if (date < 10) {
      date = '0' + date
    }
    var hour = t.getHours()
    if (hour < 10) {
      hour = '0' + hour
    }
    var minute = t.getMinutes()
    if (minute < 10) {
      minute = '0' + minute
    }
    var second = t.getSeconds()
    if (second < 10) {
      second = '0' + second
    }
    return year + '-' + month + '-' + date
  }
  // 年月日时分
  export const  formatDateMin = (secs) => {
    var t = new Date(secs)
    var year = t.getFullYear()
    var month = t.getMonth() + 1
    if (month < 10) {
      month = '0' + month
    }
    var date = t.getDate()
    if (date < 10) {
      date = '0' + date
    }
    var hour = t.getHours()
    if (hour < 10) {
      hour = '0' + hour
    }
    var minute = t.getMinutes()
    if (minute < 10) {
      minute = '0' + minute
    }
    var second = t.getSeconds()
    if (second < 10) {
      second = '0' + second
    }
    return (
      year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second
    )
  }
export const setDb = (num) => {
    // 补零操作
    if (num < 10) {
      return '0' + num
    } else {
      return '' + num
    }
  }
export const setTimes = (timer) => {
    var time = new Date(timer)
    var year = time.getFullYear() // 年
    var mon = setDb(time.getMonth() + 1) // 0
    var day = setDb(time.getDate()) // 24
    // var hour = setDb(time.getHours()) // 时
    // var min = setDb(time.getMinutes()) // 分
    // var sec = setDb(time.getSeconds()) // 秒
    return year + '-' + mon + '-' + day
  }
